/*
 * Copyright (c) 2012 Universidad Antonio de Nebrija.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Apache License v2.0
 * which accompanies this distribution, and is available at
 * http://www.apache.org/licenses/LICENSE-2.0.html
 * 
 * Contributors:
 *    Universidad Antonio de Nebrija - initial API, implementation and documentation
 */
package com.nebrija.riif.model;

/**
 * Auxiliar class used to define the location of a function in a string 
 * @author asanchep
 */
public class FunctionLocation {

	/** index of the string where the function starts */
	private int init;
	/** index of the string where the function end */
	private int end;
	/** name of the function */
	private String name;
	/** implementation */
	private FunctionInterface function;
	
	/**
	 * Creates a function location
	 * @param name the name of the function
	 * @param init the location where it starts in the string
	 */
	FunctionLocation(String name, int init){
		this.name=name;
		this.init=init;
		// by default we set the end to the init
		this.end=init;
		// Get the implementation from the registry that exists in the RootClass.
		function = RootClass.getRegistry().getFunction(name);
	}
		
	/**
	 * Getter for the index of the string where the function starts
	 * @return the index of the string where the function starts
	 */
	public int getInit() {
		return init;
	}

	public void setInit(int init) {
		this.init = init;
	}

	/**
	 * Getter for the index of the string where the function ends
	 * @return the index of the string where the function ends
	 */
	public int getEnd() {
		return end;
	}

	public void setEnd(int end) {
		this.end = end;
	}

	/**
	 * Getter for the name of the function 
	 * @return the name of the function
	 */
	public String getName() {
		return name;
	}

	/**
	 * Getter for the implementation of the function 
	 * @return the implementation of the function 
	 */
	public FunctionInterface getFunction() {
		return function;
	}

}
